{% extends "base.html" %}

{% block header%}
<title>物料配置编辑</title>
{% endblock %}

{% block content %}
{% with model_name='Material' url_prefix='/pack/material/material' %}
<div class="bar">
	<a>物料管理</a> -> 物料配置编辑
	<div class="buttons">
		<a  class="btn btn-app btn-grey btn-xs radius-4 pull-right submit"  />保存</a>
	</div>
</div>

<form action="{{url_prefix}}?id={{model.id}}" method="post">
	<table class="form2">
	<tr>
        <th>项目名称：</th>
        <td>
            <select id="project_select" name="project">
                {% for p in project_objs %}
                    <option value="{{p.id}}" {% if model.project.id == p.id %}selected="selected"{% endif %}>{{p.pro_name}}</option>
                {% endfor %}
            </select>
        </td>
	</tr>
    <tr>
		<th>渠道(SDK)名称：</th>
        <td>
            <select id="channel_select" name="channel">
                    <option value="">无</option>
            {% if now_channel_lis %}
                {% for c_id, c_name in now_channel_lis %}
                    <option value="{{c_id}}" {% if c_id == model.channel.id %}selected="selected"{% endif %}>{{c_name}}</option>
                {% endfor %}
            {% endif %}

            </select>
        </td>
	</tr>
	<tr>
        <th>平台:</th>
        <td>
            <select id="plat_select" name="plat">
                {% for v,n in plat %}
                    <option value="{{v}}" {% if model.plat == v %}selected="selected"{% endif %}>{{n}}</option>
                {% endfor %}
            </select>
        </td>
    </tr>
    <tr>
		<th>物料名称：</th>
        <td>
            <input type="text" name="param_folder" value="{{model.param_folder}}" required="required" />
        </td>
	</tr>
</table>
</form>
<script>
    var pro_channel_dict = {{ pro_channel_dic | safe }}
    $(function(){
        var channel_select = $("#channel_select");
        var project_select = $("#project_select");
        project_select.change(function () {
            channel_select[0].options.length=0;
            channel_select.append("<option value=''>无</option>");
            var channel_options = pro_channel_dict[$("#project_select").val()];
            for(var i in channel_options){
                channel_select.append("<option value='" + channel_options[i][0] + "'>" + channel_options[i][1] + "</option>");
            }
        });
        {% if not now_channel_lis %}
            project_select.change();
        {% endif %}
    })
</script>
{% endwith %}
{% endblock %}